package com.hwl.demo22;

import com.hwl.demo22.entity.Context;
import com.hwl.demo22.service.AbstractExpression;
import com.hwl.demo22.service.impl.NonterminalExpression;
import com.hwl.demo22.service.impl.TerminalExpression;

import java.util.ArrayList;
import java.util.List;

/**
 * 解释器模式
 *
 * @author sentry
 * @since 2023-03-26
 */
public class Main {

    public static void main(String[] args) {
        Context context = new Context();
        List<AbstractExpression> list = new ArrayList<>();
        list.add(new TerminalExpression());
        list.add(new NonterminalExpression());
        list.add(new TerminalExpression());
        list.add(new TerminalExpression());

        for (AbstractExpression exp : list) {
            exp.interpret(context);
        }
    }
}
